package yq.test.demo.Admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import yq.test.demo.Admin.domain.Admin;
import yq.test.demo.Admin.service.AdminService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("indexInfo")
    public String login(){
        return "Admin/index";
    }
    @RequestMapping("all")
    public String All(){
        return "Admin/all";
    }
    @RequestMapping(value = "loginInfo",method = {RequestMethod.GET,RequestMethod.POST})
    public String loginIn(HttpServletRequest request, HttpSession session){
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        Admin check = adminService.login(username,password);
        if (check.equals(null)){
            return "redirect:";
        }else {
            return "redirect:/all";
        }
    }
}
